package com.tqjc.system.core.threadpool;

import com.tqjc.system.core.util.SpringUtils;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author 86195
 * @version 1.0
 * @description 线程管理类
 * @date 2023/11/9 16:10
 */
public class ThreadPoolManager {

    private ThreadPoolManager(){}



    private static ThreadPoolManager INSTANCE = new ThreadPoolManager();

    private ThreadPoolExecutor threadPool = SpringUtils.getBean("threadPoolExecutor");



    public static ThreadPoolManager getInstance(){
        return INSTANCE;
    }

    public void execute(Runnable runnable){
        threadPool.execute(runnable);
    }


    public void shutdown(){
        if(threadPool != null && !threadPool.isShutdown()){
            threadPool.shutdown();
        }

    }



}
